﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Phone.Controls;

namespace WindowsPhoneAppHost
{
    public partial class Detail : PhoneApplicationPage
    {
        private Button currentButton;
        public Detail()
        {
            InitializeComponent();
            currentButton = this.button1;
            testForm();
            testRemarks();
            listBox_forms.Visibility = Visibility.Collapsed;
            listBox_remarks.Visibility = Visibility.Collapsed;
            scrollViewer1.Visibility = Visibility.Collapsed;
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            {
                SolidColorBrush brush = this.button1.Background as SolidColorBrush;
                if (brush != null)
                {
                    brush.Color = Colors.White;
                }
            }
            {
                SolidColorBrush brush = this.button2.Background as SolidColorBrush;
                if (brush != null)
                {
                    brush.Color = Colors.White;
                }
            }
            {
                SolidColorBrush brush = this.button3.Background as SolidColorBrush;
                if (brush != null)
                {
                    brush.Color = Colors.White;
                }
            }
            {
                SolidColorBrush brush = (sender as Button).Background as SolidColorBrush;
                if (brush != null)
                {
                    brush.Color = Colors.Orange;
                }
            }
            Button button = sender as Button;
            listBox_forms.Visibility = Visibility.Collapsed;
            listBox_remarks.Visibility = Visibility.Collapsed;
            scrollViewer1.Visibility = Visibility.Collapsed;
            if (ReferenceEquals(button, this.button1))
            {
                listBox_forms.Visibility = Visibility.Visible;
            }
            else if (ReferenceEquals(button, this.button2))
            {
                listBox_remarks.Visibility = Visibility.Visible;
            }
            else if (ReferenceEquals(button, this.button3))
            {
                scrollViewer1.Visibility = Visibility.Visible;
            }
            this.currentButton = button;
        }

        private void testForm()
        {
            for (int i = 0; i < 5; i++)
            {
                listBox_forms.Items.Add(new ListSeperator());
                listBox_forms.Items.Add(new ListSeperator());
                listBox_forms.Items.Add(new ListSeperator());
                for (int j = 0; j < 5; j++)
                {
                    FormListBoxItem formlistBox_formsItem = new FormListBoxItem();
                    formlistBox_formsItem.Title = "报销人";
                    formlistBox_formsItem.Value = "XSX";
                    listBox_forms.Items.Add(formlistBox_formsItem);
                    listBox_forms.Items.Add(new ListSeperator());
                }
            }
        }

        private void testRemarks()
        {
            listBox_remarks.Items.Add(new ListSeperator());
            for (int i = 0; i < 10; i++)
            {
                RemarkItem content = new RemarkItem();
                listBox_remarks.Items.Add(content);
                listBox_remarks.Items.Add(new ListSeperator());
            }
        }
    }
}